package com.song.factory;

import com.song.strategy.ICal;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author Klys
 * @Date 2023/6/17 19:40
 * @Description
 * @Version 1.0
 */
@Component
public class CalFactory {
    @Resource
    List<ICal> iCals;

    public ICal getICal(Integer act) {
        //卫语句
        if (act == null) {
            return null;
        }
        assert act != null;
        return iCals.stream()
                .filter(cal -> cal.judgementCal(act))
                .findFirst().orElseThrow(() -> new RuntimeException("无该act配的策略"));
    }

}
